package com.ctshk.rpc.order.goods.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.order.goods.entity.OrderShipperInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 订单提货人信息 Mapper 接口
 * </p>
 *
 * @author 姜斌文
 * @since 2021-04-19
 */
public interface OrderShipperInfoMapper extends BaseMapper<OrderShipperInfo> {

    //INSERT INTO `ctshk-goods-order`.`t_order_shipper_info`
    // (`id`, `order_id`, `shipper`, `shipper_phone`, `shipper_store_id`, `shipper_store_name`, `shipper_store_address`,
    // `shipper_date`, `gmt_create`, `create_id`, `gmt_modified`, `modified_id`, `is_deleted`) VALUES

    @Insert({
            "<script>" +
                    "INSERT INTO `ctshk-goods-order`.`t_order_shipper_info` " +
                    "<trim prefix=\"(\" suffix=\")\" suffixOverrides=\",\">"+
                    "<if test='id != null'>`id`, </if>" +
                    "<if test='orderId != null'>`order_id`,</if>" +
                    "<if test='shipper != null'>`shipper`,</if>" +
                    "<if test='shipperPhone != null'>`shipper_phone`,</if>" +
                    "<if test='shipperStoreId != null'>`shipper_store_id`,</if>" +
                    "<if test='shipperStoreName != null'>`shipper_store_name`,</if>" +
                    "<if test='shipperStoreAddress != null'>`shipper_store_address`,</if>" +
                    "<if test='shipperDate != null'>`shipper_date`,</if>" +
                    "<if test='gmtCreate != null'>`gmt_create`,</if>" +
                    "<if test='createId != null'>`create_id`,</if>" +
                    "<if test='gmtModified != null'>`gmt_modified`,</if>" +
                    "<if test='modifiedId != null'>`modified_id`,</if>" +
                    "<if test='isDeleted != null'>`is_deleted`,</if>" +
                    "</trim>" +
                    "VALUES "+
                    "<trim prefix=\"(\" suffix=\")\" suffixOverrides=\",\">" +
                    "<if test='id != null'>#{isDeleted}, </if>" +
                    "<if test='orderId != null'>#{orderId},</if>" +
                    "<if test='shipper != null'>#{shipper},</if>" +
                    "<if test='shipperPhone != null'>#{shipperPhone},</if>" +
                    "<if test='shipperStoreId != null'>#{shipperStoreId},</if>" +
                    "<if test='shipperStoreName != null'>#{shipperStoreName},</if>" +
                    "<if test='shipperStoreAddress != null'>#{shipperStoreAddress},</if>" +
                    "<if test='shipperDate != null'>#{shipperDate},</if>" +
                    "<if test='gmtCreate != null'>#{gmtCreate},</if>" +
                    "<if test='createId != null'>#{createId},</if>" +
                    "<if test='gmtModified != null'>#{gmtModified},</if>" +
                    "<if test='modifiedId != null'>#{modifiedId},</if>" +
                    "<if test='isDeleted != null'>#{isDeleted},</if>" +
                    "</trim>"+
                    "</script>"
    })
    void insertShipperInfo(OrderShipperInfo orderShipperInfo);

    /**
     * 查询提货人地址信息
     * @param id
     * @return
     */
    @Select({
            ""
    })
    OrderShipperInfo findInfoByOrderId(@Param("orderId") Long id);
}
